<%@ page contentType="text/html; charset=UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>  
<%@ taglib prefix="nst" uri="http://www.nstechs.com/app/core"%>  
<%@ page isELIgnored="false" %>
<script>
    var rootPath = "${pageContext.request.contextPath}";
	$(document).ready(function() {				
			$(".itemDele").click(function() {
				var editrow = $(this).parents("tr");
				var editId = editrow.attr("id").replace("item_", "");
				$.ajax({
					type: "DELETE",
					url: rootPath+"/article/"+editId,
					success: function(){
						editrow.remove();
						$("#msgBox").attr('class', 'msgBoxSuccess').html("delete success");
                        $("#msgBox").parent().slideDown();
					},
					error: function(XMLHttpRequest){
						var errorInfo = $(XMLHttpRequest.responseText).find("message").text();
                        $("#msgBox").attr('class', 'msgBoxFaild').html(errorInfo);
                        $("#msgBox").parent().slideDown();
					}
				});
			});
  });
</script>

<div class="content" id="content" data-nav="nav_vendor">
    <H1>Article <span><a href="${pageContext.request.contextPath}/link/article_add"> add article</a></span></H1>
    <div class="manage">
        <div class="itemList">
            <table>
                <thead>
	                <tr>
	                
	                   <th>title</th>
			         
			           <th>operation</th>
			         
	                </tr>
                </thead>
                <tbody id="batchList" data-pagenav="batchPageNav">
	                <c:choose>
				        <c:when test="${not empty articleList}">
				             <c:forEach var="article" items="${articleList}">
				                <tr id="item_${article.id}">
				     
									<td id="itemName_">${article.title}</td>
									
									<td>
										 <a class="itemDele" href="javascript:void(0)">删除</a>
									</td>
							     </tr>
				             </c:forEach>
				        </c:when>
				        <c:otherwise>
			                 <tr>
					           <td colspan="25">no record.</td>
					        </tr>
				        </c:otherwise>
			        </c:choose>
                </tbody>
            </table>

        </div>
    </div>
</div>
